# VERSION configuration
VERSION = $(shell cat asset/VERSION)
MajorVersion = $(shell echo $(VERSION) | cut -d '.' -f 1)
MinorVersion = $(shell echo $(VERSION) | cut -d '.' -f 2)
PatchVersion = $(shell echo $(VERSION) | cut -d '.' -f 3)
NewPatchVersion = $(shell echo $(PatchVersion)+1|bc)
NewVersion = $(shell echo "$(MajorVersion).$(MinorVersion).$(NewPatchVersion)")

.PHONY: build pb


genereate_version:
	@echo "Generating version..."
	# current version add 0.0.1 to asset/VERSION
	@echo $(NewVersion) > asset/VERSION

tidy:
	@echo "Tidying dependencies..."
	@go mod tidy

build: genereate_version
	@echo "Building vdrift..."
	@CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o build/vdrift cmd/vdrift/main.go

pb: 
	@echo "Generating protobuf code..."
	protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative   pkg/proto/vdrift.proto
